package net.ib.mtalk.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.UUID;

import junit.framework.TestCase;

public class TestUUID extends TestCase {

	public void testUuid(){
		
		long msb = -2907293185422192160L;
		long lsb = -7431660176289241246L;
		// current time : 1301291668085
		// current time : 1301300162937
		// uuidTimestemp: 135205844679080000
		//135205844679080000
		//1301553947870

		UUID uuid = new UUID(msb, lsb);
		
		//long uuidTimestemp = uuid.timestamp();
		long time = uuid.timestamp();
		int clock = uuid.clockSequence();
		
		
		/*Calendar calendar = new GregorianCalendar();
		calendar.*/
		/*System.out.println("uuid.getTime():"+euuid.getTime());
		GregorianCalendar gc = new GregorianCalendar();
		gc.setTimeInMillis(135205844679080000L);
		int d = gc.get(Calendar.DATE);
		int m = gc.get(Calendar.MONTH);*/
		
		Date d = new Date(1352058446790L - 50504498920L);
		String s = TimeAdapter.Date2Str(d, "E, dd MMM yyyy HH:mm:ss Z");
		
		System.out.println("system.nano:"+s);
	}
	
	public void testUuid2(){
		long msb = -2907293185422192160L;
		long lsb = -7431660176289241246L;

		UUID uuid = new UUID(msb, lsb);
		long milliSecond = TimeAdapter.getMillisecondFromUUID(uuid);
		System.out.println("milliSecond:"+milliSecond);
	}
}
